package cn.power.win.win_power.utils;


import android.view.View;

import com.chad.library.adapter.base.BaseItemDraggableAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import cn.power.win.win_power.Device;
import cn.power.win.win_power.R;

/*
 * 可以拖拉删除的适配器
 *
 * */
public class ItemDragAdapter2 extends BaseItemDraggableAdapter<Device, BaseViewHolder> {
    public ItemDragAdapter2(List<Device> data) {
        super(R.layout.item_rec_view, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, Device item) {
        helper.setText(R.id.tv_name, item.getId());
        if (item.getId().startsWith("GPRS")) {
            helper.getView(R.id.item_tv_edit).setVisibility(View.VISIBLE);
        } else if (item.getId().startsWith("RJ45")) {
            helper.getView(R.id.item_tv_edit).setVisibility(View.VISIBLE);
        } else {
            helper.getView(R.id.item_tv_edit).setVisibility(View.INVISIBLE);
        }
        helper.addOnClickListener(R.id.item_tv_edit);
        helper.addOnClickListener(R.id.item_tv_del);
        helper.addOnClickListener(R.id.tv_name);


    }
}
